﻿@model IEnumerable<SimplCommerce.Module.Catalog.Areas.Catalog.ViewModels.CategoryMenuItem>

@inject IViewLocalizer Localizer

<ul class="navbar-nav">
    @foreach (var item in Model)
    {
        if (item.ChildItems.Any())
        {
            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="javascript:void(0);">@item.Name</a>
                <ul class="dropdown-menu">
                    <li>
                        <a class="dropdown-item" href="/@item.Slug">@Localizer["All"] @item.Name</a>
                    </li>
                    @foreach (var childItem in item.ChildItems)
                    {
                        if (childItem.ChildItems.Any())
                        {
                            <li>
                                <a class="dropdown-item dropdown-toggle" href="javascript:void(0);">@childItem.Name</a>
                                <ul class="dropdown-menu">
                                    <li><a class="dropdown-item" href="/@childItem.Slug">@Localizer["All"] @childItem.Name</a></li>
                                    @foreach (var childChildItem in childItem.ChildItems)
                                    {
                                        <li><a class="dropdown-item" href="/@childChildItem.Slug">@childChildItem.Name</a></li>
                                    }
                                </ul>
                            </li>
                        }
                        else
                        {
                            <li><a class="dropdown-item" href="/@childItem.Slug">@childItem.Name</a></li>
                        }
                    }
                </ul>
            </li>
        }
        else
        {
            <li class="nav-item"><a class="nav-link" href="/@item.Slug">@item.Name</a></li>
        }
    }
</ul>